
from datetime import timedelta
from jettube.TPS import zeep
from google.appengine.api import users
from jettube.server.utilities.urlReference import GOOGLE_REGISTER_URL

YTID = 'AI39si6IWAGDlDxxBmgpXL8OAQ718wpTSq03cD3IOkJknFLPWj6rhSVGXzYn1SH3mgmR0TsGWSLEa5rEVFnxCo5PvZpLZuXo6g'
SECRET_ACCESS_KEY = '8c52658c67d395ae2a7f40ccbe76f4353b648c09'
API_KEY = '920dc163-c83c-4d50-9e09-c24b2b6b568d'

def dateString(date):
    return ( date - timedelta( 0, 8 * 60 * 60 ) ).strftime( "%I:%M%p - %A, %B %d, %Y" )

def sendTextToJackFromSong(song):
    sms = zeep.connect( API_KEY, SECRET_ACCESS_KEY )
    sms.send_message( 'jack', song.title + ' :: ' + song.station.name )
    

def googleLink():
    user = users.get_current_user()
    if user:
        link = users.create_logout_url( '/' )
        text = 'Logged In With Google'
    else:
        link = users.create_login_url(GOOGLE_REGISTER_URL )
        text = 'Log In With Google'
    return '<a href=\"%s\">%s</a>' % ( link, text )